<!--form元素开始-->
<div class="m-t ibox-content layui-form">
    <div class="layui-form-item">
        <label class="layui-form-label">真实姓名</label>
        <div class="layui-input-block">
            <input type="text" name="username" required  lay-verify="required" placeholder="业主真实姓名" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">楼栋</label>
        <div class="layui-input-block">
            <select name="type_name" lay-verify="required">
                {volist name="_type" id="vo"}
                    <option value="{$vo.type_name}">{$vo.type_name}栋</option>
                {/volist}
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">单元</label>
        <div class="layui-input-block">
            <select name="index_name" lay-verify="required">
                {volist name="_index" id="vo"}
                    <option value="{$vo.index_name}">{$vo.index_name}单元</option>
                {/volist}
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">房间号</label>
        <div class="layui-input-block">
            <select name="home_name" lay-verify="required">
                {volist name="_home" id="vo"}
                    <option value="{$vo.home_name}">{$vo.home_name}室</option>
                {/volist}
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">手机号码</label>
        <div class="layui-input-block">
            <input type="text" name="tel" required  lay-verify="required" placeholder="业主手机号码" autocomplete="off" class="layui-input" maxlength="15">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">密码</label>
        <div class="layui-input-block">
            <input type="password" name="password" required  lay-verify="required" placeholder="注册密码" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">重复密码</label>
        <div class="layui-input-block">
            <input type="password" name="repassword" required  lay-verify="required" placeholder="在输入一次密码" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">备注</label>
        <div class="layui-input-block">
            <textarea name="notice" placeholder="业主注释（不公开）" class="layui-textarea" maxlength="200"></textarea>
        </div>
    </div>
    <button type="submit" class="layui-btn layui-btn-normal" lay-submit="" lay-filter="component-form-element">注册</button>
</div>
<!--form元素结束-->
<script>
    //Demo
    layui.use('form', function(){
        var form = layui.form;
        //监听提交
        form.on('submit(component-form-element)', function (data) {
            var index = layer.load();
            //$('.layui-btn').addClass('layui-disabled').attr('disabled','disabled');
            $.ajax({
                url:"{:url('index/user/register')}",
                type:'post',
                dataType:'json',
                data:data.field,
                success:function(res){
                    if (res.data == 1) {
                        layer.close(index);
                        layer.msg(res.message);
                        setTimeout('window.location.reload()',2000);
                    } else if (res.datas == 0) {
                        layer.close(index);
                        layer.open({
                            title: '注册失败'
                            ,content: res.message
                        });
                    } else {
                        layer.close(index);
                        layer.open({
                            title: '注册失败'
                            ,content: '出现未知错误，如果问题一直出现，您可以联系管理员或站点留言'
                        });
                    }
                },error:function () {
                    layer.close(index);
                    layer.open({
                        title: '注册失败'
                        ,content: '当前网络环境不安全，拒绝登录，请调整网络环境'
                    });
                }
            })
        });
    });
</script>